package com.LA_houseLease.app.controller.appointment;



import com.LA_houseLease.app.service.ViewAppointmentService;
import com.LA_houseLease.app.vo.appointment.AppointmentDetailVo;
import com.LA_houseLease.app.vo.appointment.AppointmentItemVo;
import com.LA_houseLease.common.result.Result;
import com.LA_houseLease.pojo.entity.ViewAppointment;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
@CrossOrigin(origins = "*")
@Slf4j
@Tag(name = "看房预约信息")
@RestController
@RequestMapping("/app/appointment")
public class ViewAppointmentController {

    @Autowired
    private ViewAppointmentService viewAppointmentService;
    @Operation(summary = "保存或更新看房预约")
    @PostMapping("/saveOrUpdate")
    public Result saveOrUpdate(@RequestBody ViewAppointment viewAppointment) {
        log.warn("保存或更新看房预约--ViewAppointmentController.saveOrUpdate");
        viewAppointmentService.saveOrUpdate(viewAppointment);
        return Result.ok();
    }

    @Operation(summary = "查询个人预约看房列表")
    @GetMapping("listItem")
    public Result<List<AppointmentItemVo>> listItem() {
        log.warn("查询个人预约看房列表--ViewAppointmentController.listItem");
        List<AppointmentItemVo> list=viewAppointmentService.AppointmentItemVoList();
        return Result.ok(list);
    }

    @GetMapping("getDetailById")
    @Operation(summary = "根据ID查询预约详情信息")
    public Result<AppointmentDetailVo> getDetailById(Long id) {
        log.warn("根据ID查询预约详情信息--ViewAppointmentController.getDetailById");
        AppointmentDetailVo appointmentDetailVo=viewAppointmentService.getAppointmentDetailVoDetailById(id);
        return Result.ok(appointmentDetailVo);
    }

}










